package com.hyj.ecp.common.taglib;



import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;


/**
 * Copyrights @ 2013  hyj
 * 
 * Filename： ***********.***** Description： ************************* Version： V2.0 Author: 胡亚军
 * Finished： 2013-06-16 History: [ Author Date Version Content ] 胡亚军 2013-06-16 V1.0 create
 * 
 */
public class UtilTag extends SimpleTagSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
 

    public  JdbcTemplate jdbcTemplate;
	
	
	private String menueId;
	
	private String optName;
	
	
	public String getOptName() {
		return optName;
	}

	public void setOptName(String optName) {
		this.optName = optName;
	}

	public String getMenueId() {
		return menueId;
	}

	public void setMenueId(String menueId) {
		this.menueId = menueId;
	}

	@Override
	public void doTag() throws JspException, IOException {
		
		getJspContext().getOut().write(getOutStr()); 

	}
	
	public String getOutStr(){
		ServletContext servletContext = ((PageContext) this.getJspContext()).getServletContext();
        WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
        jdbcTemplate = (JdbcTemplate) wac.getBean("jdbcTemplate");
        String html = "<body>"+
     "<table width = \"100%\" border = \"0\" cellspacing = \"0\" cellpadding = \"0\" class = \"Treebg\">"+
            "<tr>"+
                "<td class = \"ico5\"></td>"+
                "<td>&nbsp;{content}</td>"+
                "<td class = \"ico0\">&nbsp;</td>"+
            "</tr>"+
        "</table>"+
  "</body>";
        
		return html.replace("{content}", getString(null));
	}
	
	public String getString(List<Map<String,Object>> menues){
		String  s = "";
		if(menueId.equals("000010102")){
			s = "<span>客户管理</span> &gt; <span>客户管理</span> &gt; <span class = 'c6'>客户问题查询</span>";
			if(optName!=null&&optName.length()>0){
				s = "<span>客户管理</span> &gt; <span>客户管理</span> &gt; <a href='javascript:history.go(-1);'>客户问题查询</a> &gt; <span class = 'c6'>"+optName+"</span>";
			}
		}else if(menueId.equals("000020101")){
			s = "<span>商品管理</span> &gt; <span>商品分类管理</span> &gt; <span class = 'c6'>商品分类查询</span>";
			if(optName!=null&&optName.length()>0){
				s = "<span>商品管理</span> &gt; <span>商品分类管理</span> &gt; <a href='javascript:history.go(-1);'>商品分类查询</a> &gt; <span class = 'c6'>"+optName+"</span>";
			}
		}else if(menueId.equals("000020201")){
			s = "<span>商品管理</span> &gt;<span>商品信息管理</span> &gt; <span class = 'c6'>商品查询</span>";
			if(optName!=null&&optName.length()>0){
				s = "<span>商品管理</span> &gt; <span>商品信息管理</span> &gt; <a href='javascript:history.go(-1);'>商品查询</a> &gt; <span class = 'c6'>"+optName+"</span>";
			}
		}else if(menueId.equals("000030101")){
			s = "<span>订单管理</span> &gt;<span>客户订单管理</span> &gt; <span class = 'c6'>客户订单查询</span>";
			if(optName!=null&&optName.length()>0){
				s = "<span>订单管理</span> &gt; <span>客户订单管理</span> &gt; <a href='javascript:history.go(-1);'>客户订单查询</a> &gt; <span class = 'c6'>"+optName+"</span>";
			}
		}else if(menueId.equals("000030102")){
			s = "<span>订单管理</span> &gt;<span>客户订单管理</span> &gt; <span class = 'c6'>客户积分订单</span>";
			if(optName!=null&&optName.length()>0){
				s = "<span>订单管理</span> &gt; <span>客户订单管理</span> &gt; <a href='javascript:history.go(-1);'>客户积分订单</a> &gt; <span class = 'c6'>"+optName+"</span>";
			}
		}else if(menueId.equals("000040101")){
			s = "<span>统计分析</span> &gt;<span>客户统计</span> &gt; <span class = 'c6'>月新增客户</span>";
			if(optName!=null&&optName.length()>0){
				s = "<span>统计分析</span> &gt; <span>客户统计</span> &gt; <a href='javascript:history.go(-1);'>月新增客户</a> &gt; <span class = 'c6'>"+optName+"</span>";
			}
		}else if(menueId.equals("000050101")){
			s = "<span>系统管理</span> &gt;<span>系统用户管理</span> &gt; <span class = 'c6'>用户管理</span>";
			if(optName!=null&&optName.length()>0){
				s = "<span>系统管理</span> &gt;<span>系统用户管理</span> &gt; <a href='javascript:history.go(-1);'>用户管理</a> &gt; <span class = 'c6'>"+optName+"</span>";
			}
		}else if(menueId.equals("000060101")){
			s = "<span>系统配置管理</span> &gt;<span>系统配置管理</span> &gt; <span class = 'c6'>贵就赔配置</span>";
			if(optName!=null&&optName.length()>0){
				s = "<span>系统配置管理</span> &gt;<span>系统配置管理</span> &gt; <a href='javascript:history.go(-1);'>贵就赔配置</a> &gt; <span class = 'c6'>"+optName+"</span>";
			}
		}
		return s;
		
	}

	
  
}
